package com.shu.shiro.controller;

import com.shu.shiro.common.CodeMsg;
import com.shu.shiro.common.Result;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionController {

    @ExceptionHandler(UnknownAccountException.class)
    public Result UnknownAccountException(Exception ex) {
        return Result.error(CodeMsg.S10002);
    }
    @ExceptionHandler(IncorrectCredentialsException.class)
    public Result IncorrectCredentialsException (Exception ex) {
        return Result.error(CodeMsg.S10003);
    }
    @ExceptionHandler(Exception.class)
    public Result Exception (Exception ex) {
        return Result.error(ex.getMessage());
    }

}
